package userlogic

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/pkg/xerrors"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/service"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type BalanceIncreaseLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBalanceIncreaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BalanceIncreaseLogic {
	return &BalanceIncreaseLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *BalanceIncreaseLogic) BalanceIncrease(in *rpc.BalanceIncreaseRequest) (*rpc.BalanceIncreaseRespone, error) {
	if in.Amount < 0 {
		return nil, xerrors.ErrInvalidParameterAmount
	}
	if in.ValidMark < 0 {
		return nil, xerrors.ErrInvalidParameterValidMark
	}

	ret, err := service.BalanceIncrease(l.ctx, l.svcCtx, in, nil)
	if err != nil {
		return nil, err
	}
	return ret, nil
}
